package com.deepseek.project.data;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepseek.project.mapper.TalkInfoDeepSeekHistoryMapper;
import com.deepseek.project.model.TalkInfoDeepSeekHistory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * DeepSeek对话历史记录基础服务层
 */
@Service
public class TalkInfoDeepSeekHistoryData extends ServiceImpl<TalkInfoDeepSeekHistoryMapper, TalkInfoDeepSeekHistory> {

    /**
     * 根据对话id查询对话历史记录
     */
    public List<TalkInfoDeepSeekHistory> getHistoryListByTalkInfoId(Integer talkInfoId) {
        LambdaQueryWrapper<TalkInfoDeepSeekHistory> lambda = new LambdaQueryWrapper<>();
        lambda.eq(TalkInfoDeepSeekHistory::getTalkInfoId, talkInfoId);
        return baseMapper.selectList(lambda);
    }

    /**
     * 根据对话id删除deepSeek对话历史记录
     */
    public void deleteByTalkInfoId(Integer talkInfoId){
        LambdaQueryWrapper<TalkInfoDeepSeekHistory> lambda = new LambdaQueryWrapper<>();
        lambda.eq(TalkInfoDeepSeekHistory::getTalkInfoId, talkInfoId);
        baseMapper.delete(lambda);
    }
}
